<template>
  <div class="campus-binhai">
    <h1>温州理工滨海校区</h1>
    <input v-model="studentId" placeholder="请输入学号" />
    <button @click="searchStudent">搜索</button>
    <div v-if="studentInfo">
      <h2>学生信息</h2>
      <p>学号: {{ studentInfo.id }}</p>
      <p>姓名: {{ studentInfo.name }}</p>
      <p>年龄: {{ studentInfo.age }}</p>
      <p>专业: {{ studentInfo.major }}</p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      studentId: '',
      studentInfo: null
    };
  },
  methods: {
    searchStudent() {

      const students = [
        { id: '24219141135', name: '钟好迪',age: '24', major: '计算机科学' },
        { id: '24219141138', name: '杨顺炜',age: '101',  major: '计算机科学' },
        { id: '1003', name: '王五', age: '26', major: '网络工程' }
      ];
      this.studentInfo = students.find(student => student.id === this.studentId);
    }
  }
};
</script>